#include "Shape.h"
#include "List.h"
#include "Circle.h"
#include "Rect.h"
#include <fstream>

int main()
{
	Point p1(3, 4);
	
	Circle c1(p1, 4, RED);
	Circle c2(1, 2, 3, GREEN);
	Circle c3(5, 6, 7, BLUE);
	Rect r1;
	Rect r2(1,2,3,4, RED);
	Rect r3(7, 10, 3, 1, BLUE);


	//bool fl;
	//fl = r1 == r2;
	//fl = r1 == Rect();
	//fl = r2 == Rect (1, 2, 3, 4);

	List list1;
	list1.Ad_to(List::TO::to_tail, Circle(1,2,3));
	list1.Ad_to(List::TO::to_head, c2);
	list1.Ad_to(List::TO::to_tail, c3);
	list1.Ad_to(List::TO::to_tail, r1);
	list1.Ad_to(List::TO::to_head, r2);
	list1.Ad_to(List::TO::to_tail, r3);
	
	std::cout << list1;

	{
	List list2 = list1;
	list2.Ad_to(List::TO::to_head, Circle (7, 7, 7, GREEN));
	std::cout << list2;
	list2 = list1;
	std::cout << list2;
	}

	List list3 = List();
	list3.Ad_to(List::TO::to_head, Circle(7, 7, 7, RED));
	std::cout << list3;
	list1.RemoveOne(c3);
	list3 = list1;
	list3.RemoveOne(r1);
	list3.Ad_to(List::TO::to_head, Rect(7, 3, 7, 2, RED));
	std::cout << list3;

	std::cout << "____to_area____" << std::endl;
	list3.Sort_list(to_area);
	std::cout << list3;
	std::cout << "____to_colour____" << std::endl;
	list3.Sort_list(to_colour);
	std::cout << list3;
	std::cout << "____to_distance____" << std::endl;
	list3.Sort_list(to_distance);
	std::cout << list3;

	
	std::ofstream file("List.txt");
	file << list3;
	
	List list4;
	std::ifstream fin("List.txt");
	if (fin.is_open())
	{
		fin >> list4;
	}
	else { std::cout << "Error opening file to read " << std::endl; }
	fin.close();
	std::cout << list4;

	return 0;
}